/*
 *    Copyright (c) 2018-2025, cloud All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: cloud
 */
package com.fuyao.cloud.asset.publicbarcode.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuyao.cloud.asset.entity.AssetPublicbarcode;
import com.fuyao.cloud.asset.vo.FyAssetPublicbarcodeExcelVO;
import com.fuyao.cloud.asset.publicbarcode.mapper.AssetPublicbarcodeMapper;
import com.fuyao.cloud.asset.publicbarcode.service.AssetPublicbarcodeService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 条码库
 *
 * @author 时间的朋友
 * @date 2021-11-17 14:47:09
 */
@Service
public class AssetPublicbarcodeServiceImpl extends ServiceImpl<AssetPublicbarcodeMapper, AssetPublicbarcode> implements AssetPublicbarcodeService {

    @Override
    public List<FyAssetPublicbarcodeExcelVO> listExcel(QueryWrapper queryWrapper) {
        List<AssetPublicbarcode> publicbarCodeList = this.list(queryWrapper);
        if (CollUtil.isNotEmpty(publicbarCodeList)) {
            return publicbarCodeList.stream().map(fyAssetPublicbarcode -> {
                FyAssetPublicbarcodeExcelVO excelVO = new FyAssetPublicbarcodeExcelVO();
                BeanUtil.copyProperties(fyAssetPublicbarcode, excelVO);
                return excelVO;
            }).collect(Collectors.toList());
        }
        return Lists.newArrayList();
    }

}
